package org.gulugulubiao.mapper;

import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.gulugulubiao.dto.ProblemPageQueryDTO;
import org.gulugulubiao.entity.Problem;

import java.util.List;

@Mapper
public interface ProblemMapper {

    /**
     * 获取problem所有信息
     * @param problemId
     * @return
     */
    @Select("select * from problem where id = #{problemId}")
    Problem problemJudge(Integer problemId);

    /**
     * 新增题目
     * @param problem
     */
    @Insert("insert into problem (id,problem_description,answer,tag_id,status,problem_name) values (#{id},#{problemDescription},#{answer},#{tagId},#{status},#{problemName})")
    void add(Problem problem);

    /**
     *  显示id对应的题目
     *  @param problemId
     *  @return Problem
     */
    @Select("select * from problem where id = #{problemId}")
    Problem getProblem(Integer problemId);

    /**
     *  删除id对应的题目
     *  @param problemId
     */
    @Delete("delete from problem where id = #{problemId}")
    void deleteProblem(Integer problemId);


    /**
     * 查询题目列表
     */
    @Select("select * from problem")
    List<Problem> getAllProblem();

    /**
     * 分页查询题目列表
     * @param tagId
     * @return
     */
    Page<Problem> getProblemList(Integer tagId);
}
